<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.w3.org/1999/xhtml">
<html lang="zh-CN">
<head>
    <script type="text/javascript" th:src="@{https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js}"></script>
    <link th:href="@{https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css}" rel="stylesheet"/>
    <link th:href="@{/css/default.css}" rel="stylesheet"/>
    <link rel="icon" th:href="@{/images/favicon.ico}" type="image/x-icon"/>
    <meta charset="UTF-8"/>
    <title>优惠券模板</title>
    <style>
        .center {
            text-align:center;
        }
        table,td,th
        {
            text-align:center;
        }
    </style>
</head>

<body>
<div class="contentDiv">

    <h2 class="center"> 优惠券模板 </h2>

    <legend>
        <strong class="center">创建优惠券模板</strong>
    </legend>

    <form th:action="@{/template/thy/{action}(action=${action})}" method="post" class="form-horizontal">

        <div class="form-group">
            <label for="name" class="col-sm-2 control-label">优惠券名称:</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="name" name="name" th:value="${template.name}"
                       th:field="*{template.name}"/>
            </div>
        </div>

        <div class="form-group">
            <label for="logo" class="col-sm-2 control-label">logo:</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="logo" name="name" th:value="${template.logo}"
                       th:field="*{template.logo}"/>
            </div>
        </div>

        <div class="form-group">
            <label for="desc" class="col-sm-2 control-label">描述信息:</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="desc" name="name" th:value="${template.desc}"
                       th:field="*{template.desc}"/>
            </div>
        </div>

        <div class="form-group">
            <label for="category" class="col-sm-2 control-label">优惠券种类:</label>
            <div class="col-xs-4">
            <select class="form-control" name="category">
                <option th:each="category:${session.category}" th:value="${category.code}" th:text="${ category.description }"></option>
            </select>
            </div>
        </div>

        <div class="form-group">
            <label for="productLine" class="col-sm-2 control-label">产品线:</label>
            <div class="col-xs-4">
            <select class="form-control" name="productLine">
                <option th:each="productLine:${session.productLine}" th:value="${productLine.code}" th:text="${ productLine.description }"></option>
            </select>
            </div>
        </div>

        <div class="form-group">
            <label for="count" class="col-sm-2 control-label">总数:</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="count" name="name" th:value="${template.count}"
                       th:field="*{template.count}"/>
            </div>
        </div>

        <div class="form-group">
            <label for="userId" class="col-sm-2 control-label">创建用户:</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="userId" name="writer" th:value="${template.userId}"
                       th:field="*{template.userId}"/>
            </div>
        </div>

        <div class="form-group">
            <label for="target" class="col-sm-2 control-label">分发目标:</label>
            <div class="col-xs-4">
                <select class="form-control" name="target">
                    <option th:each="target:${session.target}" th:value="${target.code}" th:text="${ target.description }"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label for="period" class="col-sm-2 control-label">有效期规则:</label>
            <div class="col-xs-4">
                <select class="form-control" name="period">
                    <option th:each="period:${session.period}" th:value="${period.code}" th:text="${ period.description }"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label for="gap" class="col-sm-2 control-label">有效间隔:</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="gap" name="writer" th:value="${template.gap}"
                       th:field="*{template.gap}"/>
            </div>
        </div>

        <div class="form-group">
            <label for="deadline" class="col-sm-2 control-label">失效日期:</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="deadline" name="writer" th:value="${template.deadline}"
                       th:field="*{template.deadline}"/>
            </div>
        </div>

        <div class="form-group">
            <label for="quota" class="col-sm-2 control-label">优惠额度:</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="quota" name="writer" th:value="${template.quota}"
                       th:field="*{template.quota}"/>
            </div>
        </div>

        <div class="form-group">
            <label for="base" class="col-sm-2 control-label">基准:</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="base" name="writer" th:value="${template.base}"
                       th:field="*{template.base}"/>
            </div>
        </div>

        <div class="form-group">
            <label for="limitation" class="col-sm-2 control-label">领取张数限制:</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="limitation" name="writer" th:value="${template.limitation}"
                       th:field="*{template.limitation}"/>
            </div>
        </div>

        <div class="form-group">
            <label for="province" class="col-sm-2 control-label">领取省份限制:</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="province" name="writer" th:value="${template.province}"
                       th:field="*{template.province}"/>
            </div>
        </div>

        <div class="form-group">
            <label for="city" class="col-sm-2 control-label">领取城市限制:</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="city" name="writer" th:value="${template.city}"
                       th:field="*{template.city}"/>
            </div>
        </div>

        <!-- 复选商品类型 -->
        <div class="form-group">
            <label for="goodsType" class="col-sm-2 control-label">支持的商品类型:</label>
            <div class="col-xs-4">
                <input th:each="type:${session.goodsType}"  type="checkbox"
                       th:value="${type.code}" th:field="*{template.goodsType}"
                       th:checked="${#lists.contains(template.goodsType, type.code)}" th:text="${type.description}">
            </div>
        </div>

        <div class="form-group">
            <label for="weight" class="col-sm-2 control-label">权重(以逗号分隔):</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="weight" name="writer" th:value="${template.weight}"
                       th:field="*{template.weight}"/>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-offset-3 col-sm-10">
                <input class="btn btn-primary" type="submit" value="提交"/>&nbsp;&nbsp;
                <input class="btn" type="button" value="返回" onclick="history.back()"/>
            </div>
        </div>

    </form>
</div>
</body>
</html>